<?php

/**
 * @user magein
 * @date 2024/1/23 10:51
 */

namespace magein\laravel\seecms\middleware;

use Closure;
use Illuminate\Http\Request;
use magein\seecms\Factory;
use magein\seecms\library\Auth;

/**
 * 用于判断访问登录页面的时候是否已经登录
 *
 * 如果已经登录则跳转到首页
 */
class IsLoginMiddleware
{
    public function handle(Request $request, Closure $next)
    {
        $info = Auth::user()->info();
        if ($info) {
            return redirect(Factory::route('s/home/index'));
        }
        return $next($request);
    }
}
